package com.demo.config;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.retry.ImmediateRequeueMessageRecoverer;
import org.springframework.amqp.rabbit.retry.MessageRecoverer;
import org.springframework.amqp.rabbit.retry.RepublishMessageRecoverer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqRecoverConfig {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    //重试消息处理
    @Bean
    public MessageRecoverer messageRecoverer(){
        System.out.println("重试也失败的消息！");
        return new RepublishMessageRecoverer(rabbitTemplate, RabbitMqConfig.exchange, RabbitMqConfig.queue_key_3);
        //return new ImmediateRequeueMessageRecoverer();
    }
}
